package com.yuqiaotech.dbpro.myfilter;

import java.sql.SQLException;
import java.sql.Wrapper;

import com.yuqiaotech.dbpro.filter.FilterAdapter;
import com.yuqiaotech.dbpro.filter.FilterChain;
import com.yuqiaotech.dbpro.proxy.YQDataSource;
import com.yuqiaotech.dbpro.proxy.jdbc.ConnectionProxy;
import com.yuqiaotech.dbpro.proxy.jdbc.ResultSetProxy;
import com.yuqiaotech.dbpro.proxy.jdbc.StatementProxy;

public class LogFilter extends FilterAdapter {

	@Override
	public void init(YQDataSource dataSource) {
		// TODO Auto-generated method stub
	}
	
	@Override
	public ConnectionProxy connection_connect(FilterChain chain)
			throws SQLException {
		System.out.println("LogFilter connection_connect");
		return chain.connection_connect();
	}

	@Override
	public void connection_close(FilterChain chain, ConnectionProxy connection)
			throws SQLException {
		System.out.println("LogFilter connection_close");
		chain.connection_close(connection);
	}

	@Override
    public StatementProxy connection_createStatement(FilterChain chain, ConnectionProxy connection) throws SQLException {
		System.out.println("LogFilter statement_create");
        return chain.connection_createStatement(connection);
    }
	
	@Override
    public void statement_close(FilterChain chain, StatementProxy statement) throws SQLException {
		System.out.println("LogFilter statement_close");
        chain.statement_close(statement);
    }
	
	public ResultSetProxy statement_executeQuery(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
		System.out.println("LogFilter statement_executeQuery");
		return chain.statement_executeQuery(statement, sql);
	}
	
	@Override
    public void resultSet_close(FilterChain chain, ResultSetProxy resultSet) throws SQLException {
		System.out.println("LogFilter resultset_colse");
        chain.resultSet_close(resultSet);
    }

}
